package com.df.bpm.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.df.bpm.dto.BusinessInformationDTO;
import com.df.bpm.dto.BusinessOutputDTO;
import com.df.bpm.mapper.BusinessOutputDTOMapper;
import com.df.common.service.impl.BaseServiceImpl;
import com.df.bpm.entity.BusinessOutputs;
import com.df.bpm.mapper.BusinessOutputsMapper;
import com.df.bpm.service.BusinessOutputsService;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@RequiredArgsConstructor
public class BusinessOutputsServiceImpl extends BaseServiceImpl<BusinessOutputsMapper,BusinessOutputs> implements BusinessOutputsService {
	private final BusinessOutputsMapper businessOutputsMapper;
    private final BusinessOutputDTOMapper businessOutputDTOMapper;

    /**
     * 按输出物查询目标业务
     * @param entityId 输出物实体ID
     * @return 业务扩展担当者名称的Dto
     */
    public List<BusinessInformationDTO> getBusinessDto(Integer entityId) {
        return businessOutputsMapper.getBusinessesDtoUnRepeat(entityId);
    }

    /**
     * 按业务ID查输出物清单
     * @param businessInformationIndex 业务ID
     * @return 输出物Dto
     */
    public List<BusinessOutputDTO> getOutputDto(Integer businessInformationIndex) {
        QueryWrapper<BusinessOutputDTO> wrapper4Output=new QueryWrapper<>();
        wrapper4Output.eq("businessInformationIndex", businessInformationIndex);
        return businessOutputDTOMapper.selectList(wrapper4Output);
    }
}